#include "LifeDrop.h"
#include <PA9.h>

LifeDrop::LifeDrop()
{

}

LifeDrop::LifeDrop(signed int xPos, signed int yPos, Creature * theCreature, int spriteNr)
{
	// The life drop will disapear eventualy
	m_lifeTime = DEFAULT_LIFETIME;

	m_iYPos = xPos;
	m_iXPos = yPos;
	m_spriteNr = spriteNr;

	m_bAlive = true;

	m_pCreature = theCreature;

	if(theCreature == NULL)
	{
		m_lifeTime = 0;
	}
}

LifeDrop::~LifeDrop()
{

}

void LifeDrop::Tick()
{
	m_lifeTime--;
	if( m_lifeTime <= 0 )
	{
		Die();
		return;
	}

	if( m_pCreature->IsHit(m_iXPos+CREATURE_SPRITE_SIZE/2, m_iYPos+CREATURE_SPRITE_SIZE/2) )
	{
		m_pCreature->LifeUp();
		Die();
	}
}

void LifeDrop::Die()
{
	m_bAlive = false;
	// Remove myself and call destructor
}
